import Vue from "vue";
import VueRouter from "vue-router";
import {StaticRoutes, MenuRoutes} from "./routes"
import BasicLayout from '../layouts/index.vue'

Vue.use(VueRouter);
const router = new VueRouter({
  base: __dirname,
  // mode: 'hash',
  routes: [
    ...StaticRoutes,
    {
      path: "/",
      name: "main",
      redirect: "/login",
      component: BasicLayout,
      children: MenuRoutes
    },
    {
      path: '*',
      redirect: '/exception/404'
    }
  ],
});
/**
 *  在进入路由之前每次都会执行此方法 全局钩子
 */
router.beforeEach((to, from, next) => {
  document.title = to.meta.title;
  next();
});
router.afterEach(function (to) {
});
export default router;
